﻿using System.Collections.Generic;

namespace AppFuscator.MapDecoder
{
    public class Field : BaseNode<Type, Field>
    {
        public Field(string name, Type parent, Field nodeLink)
            : base(name, parent, nodeLink)
        {
        }
    }

    public class Method : BaseNode<Type, Method>
    {
        public List<Parameter> Parameters { get; set; }

        public string ReturnTypeName { get; set; }

        public string AssembleName
        {
            get { return Parent.AssembleName; }
            set { }
        }

        public Method(string name, Type parent, Method nodeLink)
            : base(name, parent, nodeLink)
        {
            Parameters = new List<Parameter>();
        }

        public override string ToString()
        {
            return Name;
        }

        public string FullName
        {
            get
            {
                if (Parent.Name.Length > 0)
                {
                    return (Parent.NameSpace.Length > 0) ?
                        string.Format("{0}.{1}.{2}({3})", Parent.NameSpace, Parent.Name, Name, string.Join(", ", Parameters))
                        : string.Format("{0}.{1}({2})", Parent.Name, Name, string.Join(", ", Parameters));
                }
                return string.Format("{0}({1})", Name, string.Join(", ", Parameters));
            }
        }
    }

    public class Property : BaseNode<Type, Property>
    {
        public Property(string name, Type parent, Property nodeLink)
            : base(name, parent, nodeLink)
        {
        }
    }

    public class Event : BaseNode<Type, Event>
    {
        public Event(string name, Type parent, Event nodeLink)
            : base(name, parent, nodeLink)
        {
        }
    }

    public class Parameter : BaseNode<Method, Parameter>
    {
        public string TypeName { get; set; }

        public Parameter(string typename, string name, Method parent, Parameter nodeLink)
            : base(name, parent, nodeLink)
        {
            TypeName = typename;
        }

        public Parameter(string typename, Method parent, Parameter nodeLink)
            : this(typename, null, parent, nodeLink)
        {
        }

        public override string ToString()
        {
            return TypeName + Name;
        }
    }
}